﻿using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UI.Tools
{
    class OP_AppSettings
    {
        public static AppSettings LoadJson(string jsonPath)
        {
            var str = File.ReadAllText(jsonPath);
            return Tools.JsonHelper.ToObject<AppSettings>(str);

        }

        public static void SaveJson(string jsonPath, string json)
        {
            File.WriteAllText(jsonPath, json);
        }
    }


    public partial class AppSettings : ObservableObject
    {
        [ObservableProperty]
        private string _AppNameCN;
        [ObservableProperty]
        private int _AppNameCN_FontSize;
        [ObservableProperty]
        private string _AppNameEN;
        [ObservableProperty]
        private int _AppNameEN_FontSize;
        [ObservableProperty]
        private int _TitleWidth;
        [ObservableProperty]
        private string _CompanyName;
        [ObservableProperty]
        private string _AppVersion;
        [ObservableProperty]
        private string _DefaultShiYanShuJuRootPath;
        [ObservableProperty]
        private bool _AutoFill_LoginInformation;
        [ObservableProperty]
        private string _DefaultUserName;
        [ObservableProperty]
        private string _DefaultUserPassword;
        /// <summary>
        /// 实时数据临时最大保存数量。
        /// 为了实时曲线显示限制作用。
        /// </summary>
        [ObservableProperty]
        private int _RealTimeTableRowsMaxCount;
        [ObservableProperty]
        /// <summary>
        /// 开发者模式，自动显示答案。
        /// </summary>
        private bool _DevelopMode;
        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        [ObservableProperty]
        private string _DBConnectionString;
        [ObservableProperty]
        private string _Root_Url;

        public AppSettings()
        { }
    }
}
